package com.lanou.controller;

import com.github.pagehelper.PageInfo;
import com.lanou.bean.*;
import com.lanou.service.PageService;
import com.sun.tools.javac.util.List;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * Created by dllo on 18/3/14.
 */
@Controller
public class PageController {
    @Resource
    private PageService pageService;

    /**
     * 角色信息分页
     * @param pageNo
     * @param pageSize
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/rolepage")
    public PageInfo<RoleGuanLiBean> roleBypage(@RequestParam(value = "pageNum") Integer pageNo,
                                     @RequestParam(value = "pageSize") Integer pageSize){

        //pageNum 当前页
        //pageSize显示几条数据
        return pageService.selectRoleByPage(pageNo,pageSize);
    }

    /**
     * 管理员信息分页
     * @param pageNo
     * @param pageSize
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/adminpage")
    public PageInfo<AdminModule> adminpage(@RequestParam(value = "pageNum") Integer pageNo,
                                           @RequestParam(value = "pageSize") Integer pageSize){
        return pageService.selectAdminByPage(pageNo, pageSize);
    }

    /**
     * 资费信息分页
     * @param pageNo
     * @param pageSize
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/costpage")
    public PageInfo<Cost> costpage(@RequestParam(value = "pageNum") Integer pageNo,
                                   @RequestParam(value = "pageSize") Integer pageSize){
        return pageService.selectCostByPage(pageNo, pageSize);
    }

    /**
     * 账务账号信息分页
     * @param pageNo
     * @param pageSize
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/accountpage")
    public PageInfo<Account> accountpage(@RequestParam(value = "pageNum") Integer pageNo,
                                         @RequestParam(value = "pageSize") Integer pageSize){
        return pageService.selectAccountByPage(pageNo, pageSize);
    }

    /**
     * 业务账号信息分页
     * @param pageNo
     * @param pageSize
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/servicepage")
    public PageInfo<Service> servicepage(@RequestParam(value = "pageNum") Integer pageNo,
                                         @RequestParam(value = "pageSize") Integer pageSize){
        return pageService.selectServiceByPage(pageNo, pageSize);
    }

    @ResponseBody
    @RequestMapping(value = "/servicesearch")
    public PageInfo<Service> servicesearch(@RequestParam(value = "pageNum") Integer pageNo,
                                         @RequestParam(value = "pageSize") Integer pageSize,
                                           @RequestParam(value = "loginName") String loginName,
                                           @RequestParam(value = "idCardNo") String idCardNo,
                                           @RequestParam(value = "realName") String realName){
        return pageService.selectServiceBySearch(pageNo,pageSize,loginName,idCardNo,realName);
    }


    @ResponseBody
    @RequestMapping(value = "/accountsearch")
    public PageInfo<Account> accountSearch (@RequestParam(value = "pageNum") Integer pageNo,
                                           @RequestParam(value = "pageSize") Integer pageSize,
                                           @RequestParam(value = "loginName") String loginName,
                                           @RequestParam(value = "idCardNo") String idCardNo,
                                           @RequestParam(value = "realName") String realName,
                                            @RequestParam(value = "status" ) int status){
        return pageService.accountSearch(pageNo,pageSize,idCardNo,realName,loginName,status);
    }

    @ResponseBody
    @RequestMapping(value = "/adminSearch")
    public PageInfo<AdminModule> roleSearch (@RequestParam(value = "pageNum") Integer pageNo,
                                                @RequestParam(value = "pageSize") Integer pageSize,
                                                @RequestParam(value = "name") String name){
        System.out.println(name);
        return pageService.searchAdminInfo(pageNo,pageSize,name);
    }

}
